from langchain_community.chat_models import ChatTongyi
from langchain_core.prompts.prompt import PromptTemplate
from langchain.chains import LLMChain

import os

os.environ["DASHSCOPE_API_KEY"] = "sk-9d8f1914800e497f8717144e860f99bc"
# 定义模型
llm = ChatTongyi()

# 定义提示
template = """
You are an expert data scientist with an expertise in building deep learning models.
Explain the concept of {concept} in a couple of lines
"""
prompt = PromptTemplate(
    input_variables=["concept"],
    template=template,
)

# 设置链
chain = LLMChain(llm=llm, prompt=prompt, verbose=True)

# 调用链
result = chain.invoke("deep learning")
print(result.get('text'))
